﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using Baosight.Platform.Core.UI.Controls;
using Baosight.Platform.Core;
using Baosight.ZNH.ZMCommon;
using Baosight.ZNH.ZMCommon.ChildWindows;
using Telerik.Windows.Controls;
using System.Collections.ObjectModel;
using System.Windows.Browser;
using System.Text;


namespace Baosight.ZNH.ZMCT.UI
{
    public partial class ZMCT32 : EFViewCmes
    {
        public ZMCT32()
        {
            InitializeComponent();
            base.BeforeAction += OnBeforeAction;
        }
        /// <summary>
        /// 新增/修改前设置属性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnBeforeAction(object sender, EventArgs e)
        {
            EFViewCmesProperty _view = new EFViewCmesProperty();
            _view.EFGridCheckedRows = this.grid.GetCheckedEIRows();
            base.ViewProperty = _view;
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="initData"></param>
        public override void Initialize(Platform.Core.EIInfo initData)
        {
            base.Initialize(initData);
        }
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CommitClick(object sender, RoutedEventArgs e)
        {
            EIInfo retData = new EIInfo();
            retData.Set("choiceName", "sssss");
            string no = "";
            string name = "";
            string phone = "";
            for (int i = 0; i < this.grid.GetCheckedEIRows().Count; i++)
            {
                no += this.grid.GetCheckedEIRows()[i]["fdNo"];
                name += this.grid.GetCheckedEIRows()[i]["fdName"];
                phone+=this.grid.GetCheckedEIRows()[i]["fdMobilePhone"];
                if (!no.Equals("") && !no.EndsWith(";"))
                {
                    no+=";";
                }
                if (!name.Equals("") && !name.EndsWith(";"))
                {
                    name += ";";
                }
                if (!phone.Equals("") && !phone.EndsWith(";"))
                {
                    phone+=";";
                }
            }
            EIBlock block = retData.AddBlock("VALUES");
            //EIBlock block = new EIBlock("result");
            EIColumn choiceName = new EIColumn();
            choiceName.Name = "choiceName";
            EIColumn fdNo = new EIColumn();
            fdNo.Name = "fdNo";
            EIColumn fdPhone = new EIColumn();
            fdPhone.Name = "fdPhone";
            block.AddColumn(fdNo);
            block.AddColumn(choiceName);
            block.AddColumn(fdPhone);
            EIRow row = new EIRow();
            row.Add("choiceName", name);
            row.Add("fdNo",no);
            row.Add("fdPhone",phone);
            block.AddRow(row);
            NotifyViewDataChanged(retData);
//            base.OnCommitButtonClick("ZMCT30", sender, e);
        }
        /// <summary>
        /// 清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clean_Click(object sender, RoutedEventArgs e)
        {
            NotifyViewDataChanged("");
        }
    }
}